package com.jevons.geopackagesdk;

import android.os.Bundle;
import android.os.Handler;

import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModel;

import com.jevons.geo_edit.activity.GisMapActivity;
import com.jevons.geo_edit.geopackage.GisMapGeoManger;
import com.jevons.muffin.activity.BaseCheckPermissionActivity;

import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;

/**
 * Copyright 2020 JxGIS
 *
 * @file SplashActivity
 * @auth linaisheng
 * Created on 2024/5/17.
 * Description：
 */
public class SplashActivity extends BaseCheckPermissionActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        DataBindingUtil.setContentView(
                this, R.layout.activity_splash);
        if (checkPermission()) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    jumpPage();
                }
            }, 1 * 1000);

        }
    }

    @Override
    protected String[] getNeedPermissions() {
        String[] permissions = {
                WRITE_EXTERNAL_STORAGE
        };
        return permissions;
    }

    @Override
    protected void permissionGrantedSuccess() {
        jumpPage();
    }

    @Override
    protected ViewModel initViewModel() {
        return null;
    }

    private void jumpPage() {
        GisMapGeoManger.checkExistDbFileAndCreate(this);
        startActivity(GisMapActivity.getStartIntent(getContext(), "fad27b0852e84fffbd7482bd0a5fc1c5", null, false));
        finish();
    }

}